const INFO_KEY = 'hm_shopping_info'
const HISTORY_KEY = 'hm_history_info'

export const getUserInfo = () => {
  const result = localStorage.getItem(INFO_KEY)
  return result ? JSON.parse(result) : { token: '', userId: '' }
}

export const setUserInfo = (obj) => {
  localStorage.setItem(INFO_KEY, JSON.stringify(obj))
}

export const removeUserInfo = () => {
  localStorage.removeItem(INFO_KEY)
}

export const getHistoryInfo = () => {
  const result = localStorage.getItem(HISTORY_KEY)
  return result ? JSON.parse(result) : []
}

export const setHistoryInfo = (obj) => {
  localStorage.setItem(HISTORY_KEY, JSON.stringify(obj))
}
